<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * 文本框控件FDTextBox,继承自&lt;a href="FDFieldComponent.html">FDFieldComponent&lt;/a>&lt;br>
<span class='line'>  3</span>  * @example 示例:&lt;br>
<span class='line'>  4</span>  * &lt;pre>&lt;code>
<span class='line'>  5</span> // 设置JS路径
<span class='line'>  6</span> FDLib.setDir('../../src/');
<span class='line'>  7</span> 
<span class='line'>  8</span> var txtUsername;
<span class='line'>  9</span> var txtPassword
<span class='line'> 10</span> 
<span class='line'> 11</span> FDLib.loadJs(['FDTextBox','FDPasswordBox'],function() {
<span class='line'> 12</span> 	txtUsername = new FDTextBox({name:"username",defaultValue:'请输入姓名'
<span class='line'> 13</span> 		,validates:[new FDValidate({errorMsg:'请输入正整数',items:['positiveInt']})]});
<span class='line'> 14</span> 	
<span class='line'> 15</span> 	
<span class='line'> 16</span> 	txtUsername.addEvent('blur',function(e){
<span class='line'> 17</span> 		//alert(e.target.value);
<span class='line'> 18</span> 	})
<span class='line'> 19</span> 	
<span class='line'> 20</span> 	txtPassword = new FDPasswordBox({domId:'password',name:'password',label:'密码:'});
<span class='line'> 21</span> 	
<span class='line'> 22</span> 	var text2 = new FDTextBox({domId:'addr',width:200,height:40,name:'addr',label:'地址:',labelValign:'top'});
<span class='line'> 23</span> 	text2.addEvent('change',function(e){
<span class='line'> 24</span> 		alert(e.target.value);
<span class='line'> 25</span> 	})
<span class='line'> 26</span> });&lt;/code>&lt;/pre>
<span class='line'> 27</span> * @param options 参见&lt;a href="FDFieldComponent.html#getOptions">FDFieldComponent.getOptions()&lt;/a>&lt;br>
<span class='line'> 28</span> * @constructor
<span class='line'> 29</span>  */</span><span class="WHIT">
<span class='line'> 30</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">FDTextBox</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">	</span><span class="NAME">FDTextBox.superclass.constructor.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">,</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">	</span><span class="NAME">this.options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FDLib.util.apply</span><span class="PUNC">(</span><span class="NAME">this.getOptions</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 34</span> 
<span class='line'> 35</span> </span><span class="NAME">FDLib.extend</span><span class="PUNC">(</span><span class="NAME">FDTextBox</span><span class="PUNC">,</span><span class="NAME">FDFieldComponent</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 36</span> 
<span class='line'> 37</span> </span><span class="COMM">//@override</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="NAME">FDTextBox.prototype.getOptions</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 39</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">options</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">FDTextBox.superclass.getOptions.call</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 40</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">FDLib.util.apply</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">,</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 41</span> </span><span class="WHIT">		</span><span class="NAME">defaultClassName</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'pui-inputtext ui-widget ui-state-default ui-corner-all'</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 44</span> 
<span class='line'> 45</span> </span><span class="COMM">/**
<span class='line'> 46</span>  * @private
<span class='line'> 47</span>  */</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="COMM">//@override</span><span class="WHIT">
<span class='line'> 49</span> </span><span class="NAME">FDTextBox.prototype.buildControlDom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">input</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">document.createElement</span><span class="PUNC">(</span><span class="NAME">FDTag.INPUT</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">	</span><span class="NAME">input.setAttribute</span><span class="PUNC">(</span><span class="STRN">'type'</span><span class="PUNC">,</span><span class="STRN">'text'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">	</span><span class="NAME">input.setAttribute</span><span class="PUNC">(</span><span class="STRN">'name'</span><span class="PUNC">,</span><span class="NAME">this.options.name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT">	</span><span class="NAME">input.className</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.options.defaultClassName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT">	</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">input</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 56</span> 
<span class='line'> 57</span> </span><span class="NAME">FDTextBox.prototype.initEvent</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">	</span><span class="NAME">FDLib.addHoverEffect</span><span class="PUNC">(</span><span class="NAME">this.getControlDom</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">	</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">	</span><span class="NAME">this.addEvent</span><span class="PUNC">(</span><span class="STRN">'click'</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">		</span><span class="NAME">FDLib.dom.addClass</span><span class="PUNC">(</span><span class="NAME">e.target</span><span class="PUNC">,</span><span class="STRN">'ui-state-focus'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">		</span><span class="NAME">e.stopPropagation</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT">	</span><span class="NAME">this.addEvent</span><span class="PUNC">(</span><span class="STRN">'blur'</span><span class="PUNC">,</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">		</span><span class="NAME">FDLib.dom.removeClass</span><span class="PUNC">(</span><span class="NAME">e.target</span><span class="PUNC">,</span><span class="STRN">'ui-state-focus'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">		</span><span class="NAME">e.stopPropagation</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 70</span> </span></pre></body></html>